    <?php
    define('IN_PHPBB', true);
    $phpbb_root_path = '../forum/';
    $phpEx = substr(strrchr(__FILE__, '.'), 1);
    include($phpbb_root_path . 'common.' . $phpEx);
     
    // Start session management
    $user->session_begin();
    $auth->acl($user->data);
    $user->setup();

    if($user->data['is_registered'])
    {
        echo "Welcome " . $user->data['username']; //User is already logged in
    }
    else if(isset($_POST['login']))
    {
        $username = request_var('username', '', true);
        $password = request_var('password', '', true);
        $autologin = (!empty($_POST['autologin'])) ? true : false;

        $result = $auth->login($username, $password, $autologin);

        if ($result['status'] == LOGIN_SUCCESS)
        {
            //User was successfully logged into phpBB
            $redirect = request_var('redirect', "{$phpbb_root_path}index.$phpEx");

            // append/replace SID
            $redirect = reapply_sid($redirect);

            meta_refresh(0, $redirect);
            trigger_error('You have been logged in');
        }
        else
        {
            echo 'Bad Login ' . $username; //User's login failed
        }
    }
    else
    {
        echo '
            Please log in:<br />
            <form method="POST" action="_SELF">
            <p>Username: <input type="text" name="username" size="40"><br />
            Password: <input type="password" name="password" size="40"><br />
            Remember Me?: <input type="checkbox" name="autologin"><br />
            <input type="submit" value="Submit" name="login"></p>
            </form>';
    }
    ?>